home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
tbbyte.arc
/
PILOT2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-08-14
|
5KB
|
204 lines
{PASCAL VERSION OF WADUZITDO}
program waduzitdo;
const
pz=5000;
bs=127;
eol=10;
strlen=80;
type
str=string[strlen];
var
loc,lst,i,e,c : integer;
lchr,flg,cbuf,ch,curs,cbs,ceol : char;
s : str;
flag, run, done: boolean;
prog : array[1..pz] of char;
procedure chin;
begin
if flag then
begin
e := 1;
write (curs);
read(s);
flag := false
end;
if e > length(s) then
begin
e := 1;
writeln;
write (curs);
read (s);
cbuf := chr(eol)
end
else
begin
c := ord(s[e]);
if c = $1b then
begin
done := true;
c := $20
end;
ch := chr(c);
cbuf := ch;
e := e + 1
end;
end;
procedure chout;
begin
if cbuf = chr(eol) then
writeln
else
write (cbuf);
end;
procedure newline;
begin
writeln;
end;
procedure list;
var i: integer;
begin
i := 0;
loc := loc - 1;
repeat
cbuf := prog [loc];
loc := loc + 1;
i := i + 1;
chout
until (i>64) or (cbuf=ceol);
newline
end;
procedure listall;
var j : integer;
begin
j := 0;
loc := 1;
repeat
list;
j := j + 1
until (prog[loc+1] = 'S') or (j = 10);
newline
end;
procedure execute;
begin
loc :=1;
curs := '#';
repeat
cbuf := prog[loc];
if cbuf < '*' then
cbuf := '*';
if not (cbuf in ['*','Y','N','A','M','J','T','S']) then
list
else
case cbuf of
'*': loc := loc+1;
'Y': if cbuf = flg then
loc := loc + 1
else
repeat
cbuf := prog[loc];
write (cbuf);
loc := loc + 1
until cbuf = ceol;
'N': if cbuf = flg then
loc := loc + 1
else
repeat
cbuf := prog[loc];
write (cbuf);
loc := loc + 1
until cbuf = ceol;
'A' : begin
lst := loc;
chin;
lchr := cbuf;
newline;
loc := loc + 2
end;
'M' : begin
if lchr = prog[loc+2] then
flg := 'Y'
else
flg := 'N';
loc := loc + 3
end;
'J' : if prog[loc+2] = '0' then
loc := lst
else
begin
i := ord(prog[loc+2])-48;
repeat
loc := loc + 1;
if prog[loc] = '*' then
i := i - 1;
until i = 0
end;
'T' : begin
loc := loc + 2;
list
end;
'S' : begin
done := true;
loc := 1
end
end
until done
end;
begin
cbs := chr(bs);
ceol := chr(eol);
cbuf := '\';
flag := true;
run := true;
while run do
begin
curs := '*';
if cbuf = '\' then
loc := 1
else if cbuf = cbs then
loc := loc - 1
else if cbuf = '/' then
list
else if cbuf = '=' then
listall
else if cbuf = '$' then
begin
done := false;
execute
end
else if cbuf = '!' then
run := false
else if cbuf = '%' then
begin
i := 0;
while (i<64) and (prog[loc] <> ceol) do
begin
prog[loc] := chr(0);
loc := loc + 1
end;
prog[loc] := ceol;
loc := loc + 1
end
else begin
prog[loc] := cbuf;
loc := loc + 1
end;
if run then
begin
curs := '*';
chin
end
end
end.